<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1">
  <title id="cj20941">ALTER MATERIALIZED VIEW</title>
  <body>
    <p id="sql_command_desc">Changes the definition of a materialized view.</p>
    <section id="section2">
      <title>Synopsis</title>
      <codeblock id="sql_command_synopsis">ALTER MATERIALIZED VIEW [ IF EXISTS ] <varname>name</varname> <varname>action</varname> [, ... ]
ALTER MATERIALIZED VIEW [ IF EXISTS ] <varname>name</varname>
    RENAME [ COLUMN ] <varname>column_name</varname> TO <varname>new_column_name</varname>
ALTER MATERIALIZED VIEW [ IF EXISTS ] <varname>name</varname>
    RENAME TO <varname>new_name</varname>
ALTER MATERIALIZED VIEW [ IF EXISTS ] <varname>name</varname>
    SET SCHEMA <varname>new_schema</varname>
ALTER MATERIALIZED VIEW ALL IN TABLESPACE <varname>name</varname> [ OWNED BY <varname>role_name</varname> [, ... ] ]
    SET TABLESPACE <varname>new_tablespace</varname> [ NOWAIT ]

where <varname>action</varname> is one of:

    ALTER [ COLUMN ] <varname>column_name</varname> SET STATISTICS <varname>integer</varname>
    ALTER [ COLUMN ] <varname>column_name</varname> SET ( <varname>attribute_option</varname> = <varname>value</varname> [, ... ] )
    ALTER [ COLUMN ] <varname>column_name</varname> RESET ( <varname>attribute_option</varname> [, ... ] )
    ALTER [ COLUMN ] <varname>column_name</varname> SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
    CLUSTER ON <varname>index_name</varname>
    SET WITHOUT CLUSTER
    SET ( <varname>storage_paramete</varname>r = <varname>value</varname> [, ... ] )
    RESET ( <varname>storage_parameter</varname> [, ... ] )
    OWNER TO <varname>new_owner</varname></codeblock>
    </section>
    <section id="section3">
      <title>Description</title>
      <p><codeph>ALTER MATERIALIZED VIEW</codeph> changes various auxiliary properties of an
        existing materialized view.</p>
      <p>You must own the materialized view to use <codeph>ALTER MATERIALIZED VIEW</codeph>. To
        change a materialized view's schema, you must also have <codeph>CREATE</codeph> privilege on
        the new schema. To alter the owner, you must also be a direct or indirect member of the new
        owning role, and that role must have <codeph>CREATE</codeph> privilege on the materialized
        view's schema. (These restrictions enforce that altering the owner doesn't do anything you
        couldn't do by dropping and recreating the materialized view. However, a superuser can alter
        ownership of any view anyway.)</p>
      <p>The statement subforms and actions available for <codeph>ALTER MATERIALIZED VIEW</codeph>
        are a subset of those available for <codeph>ALTER TABLE</codeph>, and have the same meaning
        when used for materialized views. See the descriptions for <codeph><xref
            href="ALTER_TABLE.xml"/></codeph> for details.</p>
    </section>
    <section id="section4">
      <title>Parameters</title>
      <parml>
        <plentry>
          <pt><varname>name</varname></pt>
          <pd>The name (optionally schema-qualified) of an existing materialized view.</pd>
        </plentry>
        <plentry>
          <pt><varname>column_name</varname></pt>
          <pd>Name of a new or existing column.</pd>
        </plentry>
        <plentry>
          <pt><varname>new_column_name</varname></pt>
          <pd>New name for an existing column.</pd>
        </plentry>
        <plentry>
          <pt><varname>new_owner</varname></pt>
          <pd>The user name of the new owner of the materialized view.</pd>
        </plentry>
        <plentry>
          <pt><varname>new_name</varname></pt>
          <pd>The new name for the materialized view.</pd>
        </plentry>
        <plentry>
          <pt><varname>new_schema</varname></pt>
          <pd>The new schema for the materialized view.</pd>
        </plentry>
      </parml>
    </section>
    <section id="section6">
      <title>Examples</title>
      <p>To rename the materialized view foo to bar:</p>
      <pre>ALTER MATERIALIZED VIEW foo RENAME TO bar;</pre>
    </section>
    <section id="section7">
      <title>Compatibility</title>
      <p><codeph>ALTER MATERIALIZED VIEW</codeph> is a Greenplum Database extension of the SQL
        standard.</p>
    </section>
    <section id="section8">
      <title>See Also</title>
      <p><codeph><xref href="CREATE_MATERIALIZED_VIEW.xml"/></codeph>, <codeph><xref
            href="DROP_MATERIALIZED_VIEW.xml"/></codeph>, <codeph><xref
            href="REFRESH_MATERIALIZED_VIEW.xml"/></codeph></p>
    </section>
  </body>
</topic>
